<p>The <code>injectHeaders</code> field allows you to modify the request headers before
passing them on to the downstream service. To demonstrate, let's create a mirror imposter
so we can see what headers are sent. This imposter just takes the request
headers it receives and sends them back in the response:</p>

<p class='info-icon'><code>injectHeaders</code> only work for http/s proxies</p>

<testScenario name='injectHeaders'>
    <step type='http'>
<pre><code>POST /imposters HTTP/1.1
Host: localhost:<%= port %>
Content-Type: application/json

{
  "port": 7002,
  "protocol": "http",
  "name": "Mirror",
  "stubs": [{
    "responses": [{
      "is": { "body": "The body." },
      "behaviors": [
        { "decorate": "function (req, res) { res.headers = req.headers; }" }
      ]
    }]
  }]
}</code></pre>
    </step>

<p>Now let's set up another imposter that will proxy requests to the mirror imposter.
We'll also set up the inject headers field to insert some custom headers in the outgoing request:</p>

    <step type='http'>
<pre><code>POST /imposters HTTP/1.1
Host: localhost:<%= port %>
Content-Type: application/json

{
  "port": 7001,
  "protocol": "http",
  "name": "Inject Headers",
  "stubs": [{
    "responses": [{
      "proxy": {
        "to": "http://localhost:7002",
        <strong class='highlight1'>"injectHeaders": {
           "X-My-Custom-Header-One": "my first value",
           "X-My-Custom-Header-Two": "my second value"
        }</strong>
      }
    }]
  }]
}</code></pre>
    </step>

<p>Then we send a request to our proxy imposter:</p>

    <step type='http'>
<pre><code>GET / HTTP/1.1
Host: localhost:7001</code></pre>

        <assertResponse>
<pre><code>HTTP/1.1 200 OK
Host: localhost:7002
Accept: application/json
Connection: keep-alive
<strong class='highlight1'>X-My-Custom-Header-One: my first value
X-My-Custom-Header-Two: my second value</strong>
Date: <volatile>Thu, 09 Jan 2014 02:30:31 GMT</volatile>
Transfer-Encoding: chunked

The body.
</code></pre>
        </assertResponse>
    </step>

<p>Now we can see that the X-My-Custom-Header-One and Two headers were returned
back to us, reflected back from the mirror imposter after being injected into
the <i>outgoing</i> request.</p>

    <step type='http'>
<code class='hidden'>DELETE /imposters/7001 HTTP/1.1
Host: localhost:<%= port %>
Accept: application/json</code>
    </step>

    <step type='http'>
<code class='hidden'>DELETE /imposters/7002 HTTP/1.1
Host: localhost:<%= port %>
Accept: application/json</code>
    </step>
</testScenario>
